<template>
    <div v-bind:params="params" class="app-container">
        <div class="block_box">
            <div class="block1">
                <div class="left_top">
                    <div class="lt_content">
                        <div class="lt_content_list">
                            <div class="list_titile">共享种质资源种类</div>
                            <div class="list_contant">
                                <img src="@/assets/images/icon_top2.png" />
                                {{ dataInfo.bsTypeCount || "0" }}
                            </div>
                        </div>
                        <el-divider direction="vertical"></el-divider>
                        <div class="lt_content_list">
                            <div class="list_titile">共享种质资源数量</div>
                            <div class="list_contant">
                                <img src="@/assets/images/icon_top2.png" />
                                {{ dataInfo.bsSeedCount || "0" }}
                            </div>
                        </div>
                    </div>
                </div>
                <div class="left_bottom">
                    <div class="bot bot_main_box">
                        <div class="bot_item_left">
                            <div class="head_title">
                                <div>共享种质资源统计</div>
                            </div>
                            <div class="lines">
                                <LineGraph id="bargraph" :data="lineData1" :clickOnOff="false"
                                           style="width: 98%; height: 90%; ">
                                </LineGraph>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="left_bottom">
                    <div class="bot bot_main_box">
                        <div class="bot_item_left">
                            <div class="head_title">
                                <div>用户登陆统计</div>
                            </div>
                            <div class="lines">
                                <LineGraph id="linegraph" :data="lineData" :clickOnOff="false"
                                           style="width: 98%; height: 90%; ">
                                </LineGraph>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import LineGraph from "@/views/components/echarts/lineGraph";
import BarGraph from "@/views/components/echarts/barGraph";
import PieGraph from "@/views/components/echarts/pieGraph";
import {
    bsSuperCount,
    bsRightCount
} from "@/api/indexGroup/indexSuperAdmin";

let color = ["#619cff", "#E8941F"];
const hexToRgba = (hex, opacity) => {
    let rgbaColor = "";
    let reg = /^#[\da-f]{6}$/i;
    if (reg.test(hex)) {
        rgbaColor = `rgba(${parseInt("0x" + hex.slice(1, 3))},${parseInt(
            "0x" + hex.slice(3, 5)
        )},${parseInt("0x" + hex.slice(5, 7))},${opacity})`;
    }
    return rgbaColor;
};

let yData = [4757, 3254, 2454, 2011, 1654, 1211, 1211, 254];
let max = Math.max(...yData);

export default {
    name: "indexSuperAdmin",
    components: {
        LineGraph,
        BarGraph,
        PieGraph
    },
    data() {
        return {
            seedList: [],
            dataInfo: {},
            list: [],
            // 用户量折线图
            lineData: {
                color: color,
                title: {
                    text: "",
                },
                tooltip: {
                    trigger: "axis",
                    axisPointer: {
                        type: "line",
                    },
                    backgroundColor: "#fff",
                    textStyle: {
                        color: "#333",
                    },
                    extraCssText: "box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);",
                },
                legend: {
                    data: ["用户量"],
                    top: "1%",
                },
                grid: {
                    left: "3%",
                    right: "5%",
                    bottom: "0",
                    top: "25%",
                    containLabel: true,
                },
                xAxis: {
                    axisLine: {
                        lineStyle: {
                            color: "#D9D9D9",
                        },
                    },
                    axisLabel: {
                        textStyle: {
                            color: "#333",
                        },
                        interval: 0,
                        // rotate: 45,
                    },
                    type: "category",
                    boundaryGap: false,
                    data: [],
                },
                yAxis: {
                    minInterval: 1,
                    min: function (value) {
                        //取最小值向下取整为最小刻度
                        return Math.floor(value.min);
                    },
                    max: function (value) {
                        //取最大值向上取整为最大刻度
                        return Math.ceil(value.max);
                    },
                    name: "",
                    type: "value",
                    axisTick: {
                        // 轴线上的刻度线配置
                        show: false,
                    },
                    axisLabel: {
                        // show: false,
                        // formatter: "{value} ",
                        //刻度标签的内容格式器，支持字符串模板和回调函数两种形式，按照自己需求设置
                        textStyle: {
                            color: "#666",
                        },
                    },
                    nameTextStyle: {
                        color: "#666",
                        fontSize: 12,
                        lineHeight: 40,
                    },
                    // 分割线
                    splitLine: {
                        lineStyle: {
                            type: "dashed",
                            color: "#E9E9E9",
                        },
                    },
                    axisLine: {
                        show: false,
                    },
                },
                series: [{
                    top: 0,
                    name: "用户量",
                    type: "line",
                    symbol: "none", //数据交叉点样式
                    smooth: true, //true曲线; false折线
                    data: [],
                    lineStyle: {
                        normal: {
                            color: new this.$echarts.graphic.LinearGradient(
                                0,
                                0,
                                0,
                                1,
                                [{
                                    offset: 0,
                                    color: hexToRgba(color[0], 1),
                                },
                                    {
                                        offset: 1,
                                        color: hexToRgba(color[0], 1),
                                    },
                                ],
                                false
                            ),
                            shadowBlur: 7,
                            shadowColor: hexToRgba(color[0], 0.5),
                            shadowOffsetY: 8,
                        },
                    },
                    areaStyle: {
                        normal: {
                            //折线图颜色半透明
                            color: new this.$echarts.graphic.LinearGradient(
                                0,
                                0,
                                0,
                                1,
                                [{
                                    offset: 0,
                                    color: hexToRgba(color[0], 0.3), // 0% 处的颜色
                                },
                                    {
                                        offset: 1,
                                        color: hexToRgba(color[0], 0.1), // 100% 处的颜色
                                    },
                                ],
                                false
                            ),
                            shadowColor: hexToRgba(color[0], 0.1),
                            shadowBlur: 10,
                        },
                    },
                }, ],
            },
            // 种质资质
            lineData1: {
                color: color,
                title: {
                    text: ''
                },
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow',
                        shadowStyle: {
                            color: 'rgba(200, 200, 200, 0.1)',
                        },
                    },
                    backgroundColor: "#fff",
                    textStyle: {
                        color: "#333"
                    },
                    extraCssText: 'box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);'
                },
                legend: {},
                grid: {
                    left: '3%',
                    right: '50px',
                    bottom: '3%',
                    top: '3%',
                    containLabel: true
                },
                xAxis: {
                    max: function (value) {
                        return value.max
                    },
                    axisLine: {
                        lineStyle: {
                            color: '#D9D9D9'
                        }
                    },
                    axisLabel: {
                        color: '#666'
                    },
                    splitLine: {
                        show: false
                    },
                    type: 'category',
                    axisTick: {
                        alignWithLabel: true
                    },
                    nameTextStyle: {
                        color: "#666",
                        fontSize: 12,
                        lineHeight: 40
                    },
                    data: []
                },
                yAxis: {
                    minInterval: 1,
                    type: 'value',
                    axisLabel: {
                        textStyle: {
                            color: "#666"
                        }
                    },
                    nameTextStyle: {
                        color: "#666",
                        fontSize: 12,
                        lineHeight: 40
                    },
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: false
                    },
                    // 分割线
                    splitLine: {
                        lineStyle: {
                            type: "dashed",
                            color: "#E9E9E9"
                        }
                    },

                },
                series: [{
                    name: '种子数量',
                    type: 'bar',
                    itemStyle: {
                        normal: {
                            color: "#619cff",
                        },
                    },
                    barWidth: 20,
                    data: [],
                }, {
                    name: '种子数量',
                    type: 'bar',
                    itemStyle: {
                        normal: {
                            color: "#6bcb7d",
                        },
                    },
                    barWidth: 20,
                    data: [],
                }]
            },
        };
    },
    //params参数
    props: ["params"],
    created() {
        this.bsSuperCount();
        this.bsRightCount();
    },
    methods: {
        bsSuperCount() {
            bsSuperCount().then((res) => {
                this.dataInfo = res.data;
            });
        },
        bsRightCount() {
            bsRightCount().then((res) => {
                let xData = [];
                let yData = [];
                // 用户量折线图 - lineData;
                res.data.userList.forEach((element) => {
                    xData.push(element.dateTime);
                    yData.push(element.count);
                });
                this.lineData.xAxis.data = xData;
                this.lineData.series[0].data = yData;
                // 共享种质资源统计：横轴是类别，纵轴是每个类别里面的种子数量
                let xData1 = [];
                let yData1 = [];
                res.data.seedList.forEach((element) => {
                    xData1.push(element.typeName);
                    yData1.push(element.count);
                });
                this.lineData1.xAxis.data = xData1;
                this.lineData1.series[0].data = yData1;
            });
        },
    },
};

</script>

<style lang="scss" scoped>
.hourStatusList {
    display: flex;
    align-items: center;
    margin-bottom: 10px;

    &>div {
        display: flex;
        align-items: center;
        margin-right: 20px;

        .el-input {
            margin: 0 10px;
        }
    }

    .icons {
        font-size: 24px;
        color: #1890ff;
    }
}


.app-container {
    width: 100%;
    // display: flex;
    // justify-content: space-between;
    background: #f0f2f7;
    // min-height: 100vh;
    min-height: calc(100vh - 200px) !important;

    .block_box {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;

        .block1 {
            width: 100%;
            display: flex;
            flex-direction: column;

            .left_top {
                flex: 4;
                width: 100%;
                background-color: #f6f8fa;
                margin: 0px 10px 10px 0px;
                height: 20vh;

                .head_title {
                    // height: 60px;
                    width: 120px;
                    display: flex;
                    align-items: center;

                    // font-size: 17px !important;
                    // color: #333;
                    // margin: 10px 10px 10px 10px;
                    &>div:first-child {
                        // height: 14px;
                        font-family: PingFangSC-Medium;
                        font-size: 16px;
                        font-weight: 600;
                        color: #333;
                        // font-size: 17px;
                        // font-weight: 500;
                        // line-height: 14px;
                        letter-spacing: 0px;
                        // color: #333333;
                        padding: 15px 10px 15px 20px;
                    }

                    &>div:last-child {
                        width: 5px;
                    }
                }

                .lt_content {
                    height: 130px;
                    background-color: #ffffff;
                    display: flex;
                    flex-direction: row;
                    padding: 33px 23px 36px;

                    .lt_content_list {
                        flex: 1;
                        text-align: left;
                        padding: 0 20px;
                        text-align: center;

                        .list_titile {
                            height: 22px;
                            // font-family: PingFangSC-Medium;
                            font-size: 14px;
                            font-weight: 550;
                            letter-spacing: 0em;
                            color: #9BA0A4;
                            margin-bottom: 12px;
                        }

                        .list_contant {
                            font-size: 24px;
                            font-weight: 600;
                            letter-spacing: 0em;
                            color: #333333;
                            display: flex;
                            align-items: center;
                            justify-content: center;

                            img {
                                width: 30px;
                                height: 30px;
                                margin-right: 5px;
                            }
                        }
                    }

                    .el-divider--vertical {
                        display: inline-block;
                        width: 1px;
                        height: 70px; //更改竖向分割线长度
                        // margin-top: 10%;
                        margin: 0;
                        vertical-align: middle;
                        position: relative;
                    }
                }
            }

            .top {
                width: 100%;
                // height: 15vh;
                display: flex;
                align-items: center;
                justify-content: space-between;
                background-color: #ffffff;
                border-radius: 2px;

                &>div.top_item {
                    width: 49%;
                    padding: 28px 20px;
                    // background: #fff;
                    // border-radius: 5px;
                }

                .line {
                    width: 1px;
                    height: 65px;
                    background-color: #d8d8d8;
                }

                .top_item {
                    text-align: center;
                    font-size: 14px;
                    color: #000;
                    // font-weight: 600;

                    .num {
                        font-weight: 600;
                        font-size: 35px;
                        margin-bottom: 10px;
                        color: #1890ff;
                    }
                }
            }

            .left_main {
                flex: 7;
                margin-top: 5px;
            }

            .left_bottom {
                flex: 8;
                width: 100%;
                height: 100%;
                display: flex;
                align-items: flex-start;
                justify-content: space-between;
                margin-bottom: 15px;

                // justify-content: space-between;
                // background: #f6f8fa;
                .bottom1 {
                    width: 100%;
                    // margin-right: 20px;
                    height: 100%;

                    // align-items: flex-start;
                    // flex-direction: row;
                    // justify-content: space-between;

                    .lb_content {
                        padding: 20px 30px;
                        height: 400px;
                        overflow-y: auto;
                    }

                    .lb_content_list {
                        background-color: #ffffff;
                        text-align: center;
                        padding: 14px;
                        // text-align: justify;
                        flex-direction: row;
                        display: flex;
                        align-items: center;
                        justify-content: space-between;
                        border: 1px solid #ddd;
                        margin-bottom: 15px;


                        .lb_content_list_left {
                            flex: 2;
                            display: flex;
                            align-items: center;

                            .content {
                                color: #666666;
                                font-size: 14px;
                            }

                            // align-items: flex-start;
                            .img {
                                width: 157px;
                                height: 80px;
                                position: relative;

                                img {
                                    width: 100%;
                                    height: 100%;
                                    object-fit: cover;
                                    // padding-left: 18px;

                                }

                                .el-image {
                                    width: 100%;
                                    height: 100%;

                                    img {
                                        object-fit: cover;

                                    }
                                }

                                &.img1 {
                                    &::before {
                                        content: "1";
                                        position: absolute;
                                        left: 5px;
                                        top: 0;
                                        padding: 6px 5px;
                                        color: #fff;
                                        font-size: 14px;
                                        z-index: 1;
                                        text-align: center;
                                        background: linear-gradient(180deg, #C40101 0%, rgba(196, 1, 1, 0.30) 100%);
                                    }
                                }

                                &.img2 {
                                    &::before {
                                        content: "2";
                                        position: absolute;
                                        left: 5px;
                                        top: 0;
                                        padding: 6px 5px;
                                        color: #fff;
                                        font-size: 14px;
                                        z-index: 1;
                                        text-align: center;
                                        background: linear-gradient(180deg, #F5D504 0%, rgba(248, 217, 7, 0.30) 100%);
                                    }
                                }

                                &.img3 {
                                    &::before {
                                        content: "3";
                                        position: absolute;
                                        left: 5px;
                                        top: 0;
                                        padding: 6px 5px;
                                        color: #fff;
                                        font-size: 14px;
                                        z-index: 1;
                                        text-align: center;
                                        background: linear-gradient(180deg, #C2A4A1 0%, rgba(195, 167, 165, 0.30) 100%);
                                    }
                                }
                            }

                            &>div:last-child {
                                margin-left: 20px;
                            }
                        }

                        .lb_content_list_right {
                            flex: 0.8;
                            text-align: right;
                            font-size: 14px;
                            color: #842626;
                            display: flex;
                            align-items: center;
                            justify-content: flex-end;
                            padding-right: 10px;

                            img {
                                width: 13px;
                                height: auto;
                                margin-right: 5px;
                            }
                        }



                        .content_list {
                            // flex: 2.5;
                            width: 70%;
                            // padding: 5px;

                            .title {
                                margin-bottom: 10px;
                                // padding: 2px 2px 3px 0px;
                            }
                        }

                        .content {
                            flex-direction: row;
                            display: flex;
                            justify-content: space-between;
                            color: rgb(85, 82, 82);
                            padding: 1px 0 2px 0;

                            &>div:nth-child(1) {
                                font-size: 14px;
                                margin-top: 10px;
                            }

                            &>div:nth-child(2) {
                                font-size: 14px;
                                margin-top: 10px;
                            }
                        }
                    }
                }

                .bottom2 {
                    flex: 1;
                    height: 100%;

                    .lb_content_list {
                        background-color: #ffffff;
                        text-align: center;
                        padding: 14px;
                        // text-align: justify;
                        flex-direction: row;
                        display: flex;
                        justify-content: space-between;

                        // align-items: flex-start;
                        .img {
                            width: 30%;

                            img {
                                width: 100%;
                                height: 90px;
                                padding-left: 18px;
                            }
                        }

                        .content_list {
                            width: 70%;
                            // padding: 5px;

                            .title {
                                // padding: 2px 2px 3px 0px;
                            }
                        }

                        .content {
                            flex-direction: row;
                            display: flex;
                            justify-content: space-between;
                            color: rgb(85, 82, 82);
                            padding: 1px 0 2px 0;

                            &>div:nth-child(1) {
                                font-size: 14px;
                                margin-top: 10px;
                            }

                            &>div:nth-child(2) {
                                font-size: 14px;
                                margin-top: 10px;
                            }
                        }
                    }
                }

                .head_title {
                    // height: 60px;
                    width: 100%;
                    background-color: #f6f8fa;
                    // padding: 20px 10px 20px 20px;
                    display: flex;
                    align-items: center;

                    &>div:first-child {
                        // height: 14px;
                        font-family: PingFangSC-Medium;
                        font-size: 16px;
                        font-weight: 600;
                        color: #333;
                        line-height: 14px;
                        letter-spacing: 0px;

                        padding: 20px 10px 20px 20px;
                    }
                }

                .lb_content {
                    // overflow-y: scroll;
                    height: 80%;
                    background-color: #fff;

                    .lb_content_list {
                        background-color: #ffffff;
                        // text-align: center;
                        padding: 14px;
                        text-align: justify;

                        img {
                            width: 160px;
                            height: 80px;
                        }

                        .title {
                            text-align: justify;
                            font-size: 16px;
                            color: #333;
                            font-weight: 600;
                            // border_bottom: 1px #333 solid;
                        }

                        .content {
                            color: rgb(85, 82, 82);
                            // background: #000;
                            text-align: justify;
                        }

                        .list_titile {
                            height: 22px;
                            font-family: PingFangSC-Medium;
                            font-size: 16px;
                            font-weight: 500;
                            letter-spacing: 0em;
                            color: #9ba0a4;
                        }

                        .list_contant {
                            font-family: PingFangSC-Semibold;
                            font-size: 24px;
                            font-weight: 600;
                            letter-spacing: 0em;
                            color: #333333;
                            padding: 15px 10px 0 10px;

                            img {
                                width: 15px;
                                height: 15px;
                                margin-right: 10px;
                            }
                        }
                    }

                    .el-divider--vertical {
                        display: inline-block;
                        width: 1px;
                        height: 80px; //更改竖向分割线长度
                        // margin-top: 10%;
                        margin: 23px 8px;
                        vertical-align: middle;
                        position: relative;
                    }
                }
            }

            .bot {
                width: 100%;
                // background: #fff;
                // min-height: 70vh;
                // margin-top: 15px;
                border-radius: 2px;
                // padding: 15px;
                box-sizing: border-box;

                .bot_main {
                    width: 100%;
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    flex-wrap: wrap;
                    margin-top: 20px;

                    .bot_main_item {
                        width: 32%;
                        padding: 10px;
                        background: #f0f2f7;
                        border-radius: 2px;
                        margin-bottom: 15px;

                        .day {
                            text-align: right;
                            color: #3952fd;
                        }

                        .t1 {
                            margin-top: 15px;
                            text-align: center;
                            color: #333;
                            font-weight: 600;
                            font-size: 18px;
                        }

                        .t2 {
                            text-align: center;
                            color: red;
                            margin-top: 10px;
                            font-size: 12px;
                        }

                        .but_box {
                            text-align: center;
                            margin-top: 15px;
                            margin-bottom: 10px;
                        }
                    }
                }

                .box_head {
                    font-size: 16px;
                    font-weight: 600;
                    color: #333;
                    border-bottom: 1px solid #e9e9e9;
                    padding: 15px 20px;

                    display: flex;
                    align-items: center;
                    justify-content: space-between;

                    &>div:last-child {
                        font-size: 14px;
                        color: #717579;
                        font-weight: normal;
                    }
                }

                .bot_item_left {
                    width: 100%;
                    height: 35vh;
                    background: #fff;
                    // border-radius: 8px;

                    .lines {
                        box-sizing: border-box;
                        width: 100%;
                        height: calc(100% - 60px);
                        padding: 0px 15px 0;
                    }
                }

                .bot_item_right {
                    width: 49%;
                    height: 35vh;
                    background: #fff;

                    .lines {
                        box-sizing: border-box;
                        width: 100%;
                        height: calc(100% - 60px);
                        padding: 0 15px 0;
                    }
                }
            }

            .bot_main_box {
                width: 100%;
                display: flex;
                align-items: flex-start;
                justify-content: space-between;
                margin-bottom: 20px;
            }

            .line1 {
                flex: 9;
                width: 100%;
                height: 55vh;
                background: #fff;
                border-radius: 8px;

                .box_head2 {
                    padding: 20px;
                    font-size: 16px;
                    font-weight: 600;
                    color: #333;
                    border-bottom: 1px solid #e9e9e9;

                    .title {
                        // font-size: 16px;
                        // font-weight: 600;
                        // color: #333;
                    }
                }

                .lines {
                    box-sizing: border-box;
                    width: 100%;
                    height: calc(100% - 60px);
                    padding: 15px;
                }
            }
        }
    }
}

.rt_content {
    background-color: #ffffff;
}

.flex_item {
    display: flex;
    align-items: center;
}

</style>
